﻿using System;
using OpenTK;
using System.Collections.Generic;

namespace Mono.Rift.Core.Graphics
{
	public class Scene
	{
		public Container World { get; set; }
		public Vector4[] LightPos { get; set; }
		public LightingParams Lighting { get; set; }
		public List<Model> Models { get; set; }

		public Scene ()
		{
			World = new Container ();
			LightPos = new Vector4[8];
			Models = new List<Model> ();
			Lighting = new LightingParams ();
		}

		public void setAmbient(Vector4 color)
		{
			Lighting.Ambient = color;
		}

		public void addLight(Vector3 pos, Vector4 color)
		{
			var n = (int)Lighting.LightCount;
			LightPos [n] = new Vector4(pos);
			Lighting.LightColor [n] = color;
			Lighting.LightCount++;
		}

		public void clear()
		{
			World.clear ();
			Models.Clear ();
			Lighting.Ambient = Vector4.Zero;
			Lighting.LightCount = 0;
		}

		public void clearRenderer()
		{
			World.clearRenderer ();
		}

		public void render(RenderDevice renderDevice, Matrix4 view)
		{
			Lighting.update (view, LightPos);
			renderDevice.setLighting (Lighting);
			World.render (view, renderDevice);
		}
	}
}

